import { useModel } from "umi";
import compress from "gql-compress";
import { message } from "antd";

const useAddPosition = () => {
    const { graphqlFetch } = useModel("global");

    const addInstitutionPosition = async (variables, callback) => {
        let res = await graphqlFetch({
            query,
            variables,
        });
        if (!res) return;
        message.success("成功添加机构成员");
        callback && callback();
    };

    return { addInstitutionPosition };
};

const query = compress(`mutation MyMutation(
    $reType: String!
    $reUuid: UUID!
    $osUuid: UUID!
    $oiUuid: UUID!
    $omUuid: UUID
    $opUuid: UUID!
  ) {
    createOrganizationInstitutionsMember(
      input: {
        organizationInstitutionsMember: {
          oiUuid: $oiUuid
          reType: $reType
          reUuid: $reUuid
          osUuid: $osUuid
          omUuid: $omUuid
          opUuid: $opUuid
        }
      }
    ) {
      clientMutationId
    }
}`);

export default useAddPosition;
